package com.hy.mydesktop.client;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.logging.Handler;
import java.util.logging.Logger;

import org.apache.commons.collections.map.StaticBucketMap;

import com.extjs.gxt.desktop.client.Desktop;
import com.extjs.gxt.desktop.client.Shortcut;
import com.extjs.gxt.desktop.client.StartMenu;
import com.extjs.gxt.desktop.client.TaskBar;
import com.extjs.gxt.samples.resources.client.TestData;
import com.extjs.gxt.samples.resources.client.model.Stock;
import com.extjs.gxt.ui.client.GXT;
import com.extjs.gxt.ui.client.Registry;
import com.extjs.gxt.ui.client.Style.HorizontalAlignment;
import com.extjs.gxt.ui.client.Style.Scroll;
import com.extjs.gxt.ui.client.data.BaseListLoadResult;
import com.extjs.gxt.ui.client.data.BaseListLoader;
import com.extjs.gxt.ui.client.data.BaseModel;
import com.extjs.gxt.ui.client.data.BaseModelData;
import com.extjs.gxt.ui.client.data.BasePagingLoader;
import com.extjs.gxt.ui.client.data.BaseTreeModel;
import com.extjs.gxt.ui.client.data.ModelData;
import com.extjs.gxt.ui.client.data.ModelIconProvider;
import com.extjs.gxt.ui.client.data.PagingLoadConfig;
import com.extjs.gxt.ui.client.data.PagingLoadResult;
import com.extjs.gxt.ui.client.data.RpcProxy;
import com.extjs.gxt.ui.client.event.ButtonEvent;
import com.extjs.gxt.ui.client.event.ComponentEvent;
import com.extjs.gxt.ui.client.event.MenuEvent;
import com.extjs.gxt.ui.client.event.SelectionListener;
import com.extjs.gxt.ui.client.mvc.AppEvent;
import com.extjs.gxt.ui.client.mvc.Controller;
import com.extjs.gxt.ui.client.mvc.Dispatcher;
import com.extjs.gxt.ui.client.store.GroupingStore;
import com.extjs.gxt.ui.client.store.ListStore;
import com.extjs.gxt.ui.client.store.Record;
import com.extjs.gxt.ui.client.store.TreeStore;
import com.extjs.gxt.ui.client.util.IconHelper;
import com.extjs.gxt.ui.client.util.Theme;
import com.extjs.gxt.ui.client.widget.Component;
import com.extjs.gxt.ui.client.widget.Container;
import com.extjs.gxt.ui.client.widget.ContentPanel;
import com.extjs.gxt.ui.client.widget.LayoutContainer;
import com.extjs.gxt.ui.client.widget.MessageBox;

import com.extjs.gxt.ui.client.widget.Window;
import com.extjs.gxt.ui.client.widget.button.Button;
import com.extjs.gxt.ui.client.widget.button.ToolButton;
import com.extjs.gxt.ui.client.widget.form.CheckBox;
import com.extjs.gxt.ui.client.widget.form.CheckBoxGroup;
import com.extjs.gxt.ui.client.widget.form.ComboBox;
import com.extjs.gxt.ui.client.widget.form.Field;
import com.extjs.gxt.ui.client.widget.form.FormButtonBinding;
import com.extjs.gxt.ui.client.widget.form.FormPanel;
import com.extjs.gxt.ui.client.widget.form.Radio;
import com.extjs.gxt.ui.client.widget.form.RadioGroup;
import com.extjs.gxt.ui.client.widget.form.TextArea;
import com.extjs.gxt.ui.client.widget.form.TextField;
import com.extjs.gxt.ui.client.widget.form.FormPanel.Encoding;
import com.extjs.gxt.ui.client.widget.form.FormPanel.Method;
import com.extjs.gxt.ui.client.widget.grid.ColumnConfig;
import com.extjs.gxt.ui.client.widget.grid.ColumnModel;
import com.extjs.gxt.ui.client.widget.grid.EditorGrid;
import com.extjs.gxt.ui.client.widget.grid.Grid;
import com.extjs.gxt.ui.client.widget.grid.GridGroupRenderer;
import com.extjs.gxt.ui.client.widget.grid.GroupColumnData;
import com.extjs.gxt.ui.client.widget.grid.GroupingView;
import com.extjs.gxt.ui.client.widget.layout.AccordionLayout;
import com.extjs.gxt.ui.client.widget.layout.ColumnData;
import com.extjs.gxt.ui.client.widget.layout.ColumnLayout;
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
import com.extjs.gxt.ui.client.widget.layout.FlowLayout;
import com.extjs.gxt.ui.client.widget.layout.FormLayout;
import com.extjs.gxt.ui.client.widget.menu.MenuItem;
import com.extjs.gxt.ui.client.widget.toolbar.PagingToolBar;
import com.extjs.gxt.ui.client.widget.toolbar.SeparatorToolItem;
import com.extjs.gxt.ui.client.widget.toolbar.ToolBar;
import com.extjs.gxt.ui.client.widget.treepanel.TreePanel;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.core.client.GWT;
import com.google.gwt.i18n.client.DateTimeFormat;
import com.google.gwt.i18n.client.NumberFormat;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.AbstractImagePrototype;
import com.google.gwt.user.client.ui.NamedFrame;
import com.google.gwt.user.client.ui.RootPanel;
import com.hy.erp.inventory.pojo.PositionType;
import com.hy.erp.inventory.pojo.constant.PojoConstants;
import com.hy.mydesktop.client.component.event.AppEvents;
import com.hy.mydesktop.client.component.meta.GridPagingLoadConfigModel;
import com.hy.mydesktop.client.component.mvc.factory.GxtComponentControlerFactory;
import com.hy.mydesktop.client.component.type.ComponentControllerEnum;
import com.hy.mydesktop.client.component.type.ComponentTypeEnum;
import com.hy.mydesktop.client.example.PagingGridExample;
import com.hy.mydesktop.client.example.TreeGridExample;
import com.hy.mydesktop.client.example.WidgetRenderingExample;
import com.hy.mydesktop.client.mvc.base.BaseController;
import com.hy.mydesktop.client.mvc.constant.MvcConstants;
import com.hy.mydesktop.client.mvc.core.event.manager.PresenterHandleUtil;
import com.hy.mydesktop.client.mvc.logindialog.LoginController;
import com.hy.mydesktop.client.rpc.ServiceInvoker;
import com.hy.mydesktop.client.rpc.ServiceInvokerAsync;
import com.hy.mydesktop.client.rpc.reader.GxtToSeamServiceResultPagingReader;
import com.hy.mydesktop.shared.persistence.domain.gxt.GxtComponentControllerMetaModel;
import com.hy.mydesktop.shared.persistence.domain.gxt.GxtComponentMetaModel;
import com.hy.mydesktop.shared.persistence.domain.gxt.GxtComponentMetaNodeModel;
import com.hy.mydesktop.shared.persistence.domain.gxt.MyBaseModel;
import com.hy.mydesktop.shared.persistence.domain.gxt.constant.LibConstants;
import com.hy.mydesktop.shared.persistence.domain.gxt.constant.MetaDataConstants;
import com.hy.mydesktop.shared.rpc.meta.GxtToSeamServiceParameter;
import com.hy.mydesktop.shared.rpc.meta.GxtToSeamServiceResult;
import com.hy.mydesktop.shared.rpc.util.RpcDebugUtil;
import com.hy.mydesktop.shared.util.log.MyGwtFormatter;
import com.hy.mydesktop.shared.util.log.MyLoggerUtil;




/**
 * Entry point classes define <code>onModuleLoad()</code>.
 */
public class MyDesktop implements EntryPoint {
	
	// private Desktop desktop = new Desktop();
	public static final String SERVICEINVOKER = "serviceInvoker";
	public static final String DESKTOP = "desktop";
	public static final String GXTCOMPONENTMETAMODELS = "GxtComponentMetaModels";
	/**
	 * key=gxtComponentControllerMetaModelId
	 * value=rootController 
	 **/
	public static final String GXTCONTROLLER_MAP = "gxtControllerMap";
	ServiceInvokerAsync serviceInvoker = GWT.create(ServiceInvoker.class);
	
	public void load1() {
		GWT.log("HyDesktop.com.hy.mydesktop.client.MyDesktop is starting ...........................");
		GWT.log("....................................................");
		/*//更换GXT主题
		GXT.init();
		if (!Theme.GRAY.getId().equals(GXT.getThemeId())) {
			GXT.switchTheme(Theme.GRAY);
		}*/
		//更换GXT主题
		GXT.init();
		GWT.log(GXT.getThemeId());
		if (!Theme.BLUE.getId().equals(GXT.getThemeId())) {
			GXT.switchTheme(Theme.BLUE);
		}
		GWT.log(GXT.getThemeId());
		//初始化JdkLogger	
		startJdkLogger();
		//注册全局的serviceInvoker
		Registry.register(SERVICEINVOKER, serviceInvoker);
		/**
		 * 
		 */
		Registry.register(GXTCONTROLLER_MAP, new HashMap<String, BaseController>());

		Registry.register(DESKTOP, new Desktop());
			Registry.register(GXTCOMPONENTMETAMODELS, new LinkedList<GxtComponentMetaModel>());
		//设置桌面背景		
//		RootPanel.get().setStylePrimaryName("bodywallpaper");
			//RootPanel.get().add(new LoginDialog());
			/**
			 * 获得对应的Controller，
			 */
			//((DesktopController)this.getController()).getView()
			
		//事件转发器
		 Dispatcher dispatcher = Dispatcher.get();
		 /**
		  * 预先定义几种可能用到的Controller
		  */
		// dispatcher.addController(this.createDynamicController2());
		
		 LoginController loginController = new LoginController();
		 loginController.setId("loginController");
		 dispatcher.addController(loginController);
		 
		 AppEvent appEvent = new AppEvent(AppEvents.DESKTOP_USER_LOGIN);
		 appEvent.setData(MvcConstants.EVENT_NAME, "AppEvents.DESKTOP_USER_LOGIN");
		 MyLoggerUtil.printDebug(this.getClass(), "该类， 触发 AppEvents.DESKTOP_USER_LOGIN 事件");

	     Dispatcher.forwardEvent(appEvent);
			
			
		   // dispatcher.dispatch(AppEvents.DESKTOP_USER_LOGIN,RootPanel.get("body"));  	 
		// dispatcher.addController(this.createDynamicController3());
		 //Dispatcher.forwardEvent(AppEvents.DESKTOP_INIT_FOR_LOGGED_IN_USER); 		
		 //   dispatcher.dispatch(AppEvents.DESKTOP_USER_LOGIN);  
		    //this.createDynamicDesktop();
		//MessageBox box=new MessageBox();
		
		
//		RootPanel.get().add(this.getFormPaenlSubmit());
//		RootPanel.get().add(this.createGridSetModule());
//		RootPanel.get().add(new FormPanel());
	}
	
	
	public void testRpc() {
		GWT.log("single Rpc Test ...........................");
		
		//初始化JdkLogger	
		startJdkLogger();
		//注册全局的serviceInvoker
		Registry.register(SERVICEINVOKER, serviceInvoker);
		Registry.register(GXTCONTROLLER_MAP, new HashMap<String, BaseController>());

		Registry.register(DESKTOP, new Desktop());
			Registry.register(GXTCOMPONENTMETAMODELS, new LinkedList<GxtComponentMetaModel>());
		//设置桌面背景		
		RootPanel.get().setStylePrimaryName("bodywallpaper");
			
//		GxtToSeamServiceParameter g1=new GxtToSeamServiceParameter("positionTypeService" , "getAllPositonType" );
																						  //submitPersistentEntities
		GxtToSeamServiceParameter g1=new GxtToSeamServiceParameter("positionTypeService" , "submitPersistentEntities" );
		MyBaseModel[] baseModels = new MyBaseModel[2];
		baseModels[0]=new PositionType("mybasemodel0","ddddddddd");
		baseModels[0].set(PojoConstants.ENTITY_STATUS, PojoConstants.PERSIST_STATUS);
		baseModels[1]=new PositionType("mybasemodel1","ddddddddd");
		baseModels[1].set(PojoConstants.ENTITY_STATUS, PojoConstants.PERSIST_STATUS);

		List<MyBaseModel> list = new LinkedList<MyBaseModel>();
		list.add(baseModels[0]);
		list.add(baseModels[1]);
		g1.setMethodArgumentsType(MetaDataConstants.MODELDATA_ARRAY);
		g1.setMethodArguments2(list);

//		GxtToSeamServiceParameter g1=new GxtToSeamServiceParameter("positionService" , "getAllPosition" );
			//gxtToSeamServiceParameter.setServiceComponentName("componentControllerMetaModelService");
			//gxtToSeamServiceParameter.setServiceMethodName("findAllComponentControllerMetaModels");
		
			serviceInvoker.callService(g1, new AsyncCallback<GxtToSeamServiceResult>() {

				@Override
				public void onFailure(Throwable caught) {
					com.google.gwt.user.client.Window.alert("jjjjjjjj");
					com.google.gwt.user.client.Window.open("http://www.baidu.com", "name", "features");
				//	System.out.println("#### Rpc Exception is ####"+caught +" When get the List<GxtComponentMetaNodeModel>");
					caught.printStackTrace();
				}

				@Override
				public void onSuccess(GxtToSeamServiceResult result) {
					com.google.gwt.user.client.Window.open("url", "name", "features");

					BaseModel myBaseModel = (BaseModel)result.getResult();
					List<BaseModel> list = myBaseModel.get("listOfModelData");
					for (BaseModel baseModel : list) {
						for (String propertyName : baseModel.getPropertyNames()) {
							MyLoggerUtil.printDebug(this.getClass(),"属性名称:"+propertyName+",属性值:"+baseModel.get(propertyName));
						}
					}
					GxtComponentControllerMetaModel gxtComponentControllerMetaModel = null;
					com.google.gwt.user.client.Window.open("url", "name", "features");

					/*if (myBaseModel.get(MetaDataConstants.GXT_COMPONENT_CONTROLLER_METAMODEL) instanceof GxtComponentControllerMetaModel) {
						
						 gxtComponentControllerMetaModel =myBaseModel.get(MetaDataConstants.GXT_COMPONENT_CONTROLLER_METAMODEL);
					}else {
						gxtComponentControllerMetaModel = new GxtComponentControllerMetaModel();
						//gxtComponentControllerMetaModel.setBaseModel((BaseModel)myBaseModel.get(MetaDataConstants.GXT_COMPONENT_CONTROLLER_METAMODEL));
					}*/

					//com.google.gwt.user.client.Window.alert("jjjjjjjj"+gxtComponentControllerMetaModel);
					//com.google.gwt.user.client.Window.alert("ooooooo"+gxtComponentControllerMetaModel.getModels());
				}
			});

			
		 
	}
	
	public void onModuleLoad() {
		

		load1();
		//testRpc();
	   // testOneWindow();
		//testGrid();
		//testTreeGrid();


	}
	private void testTreeGrid() {
		Window window= new Window();
		window.setSize(800,500);
		window.setLayout(new FitLayout());
		window.add(new TreeGridExample());
		window.show();
		
	}


	private void testGrid() {
		Window window= new Window();
		window.setSize(800,500);
		window.setLayout(new FitLayout());
		window.add(new WidgetRenderingExample());
		window.show();
		
	}


	private void testPage2() {
		Window window= new Window();
		window.setSize(800,500);
		window.setLayout(new FitLayout());
		window.add(new PagingGridExample());
		window.show();
	}
	private void testPage() {
		final GxtToSeamServiceParameter gxtToSeamServiceParameter = new GxtToSeamServiceParameter();

		//PresenterHandleUtil.printPresenterInfoForEventHandle(this,event);
		
					
		gxtToSeamServiceParameter.setMethodArgumentsType(MetaDataConstants.MODELDATA_ARRAY);
		gxtToSeamServiceParameter.setServiceComponentName("positionTypeService");
		gxtToSeamServiceParameter.setServiceMethodName("getPageOfPersistentEntities");
		RpcDebugUtil.printGxtToSeamServiceParameterOfRpc(getClass(),gxtToSeamServiceParameter);

		RpcProxy<GxtToSeamServiceResult> proxy = new RpcProxy<GxtToSeamServiceResult>(){

			@Override
			protected void load(Object loadConfig,
					AsyncCallback<GxtToSeamServiceResult> callback) {
				//TODO 需要进行结构转换
				BaseModel[] methodArguments = new BaseModel[1];
				methodArguments[0] = new GridPagingLoadConfigModel();
				if (loadConfig instanceof PagingLoadConfig) {
					methodArguments[0] = new GridPagingLoadConfigModel(
							((PagingLoadConfig)loadConfig).getOffset(),	
							((PagingLoadConfig)loadConfig).getLimit()
						);
				}
				System.err.println("####GridDataLoadView####((PagingLoadConfig)loadConfig).getLimit()"+((PagingLoadConfig)loadConfig).getLimit());						
				/*gxtToSeamServiceParameter.setServiceComponentName("com.hy.mydesktop.server.business.PersonService");22
				gxtToSeamServiceParameter.setServiceMethodName("listPage");*/
				gxtToSeamServiceParameter.setMethodArguments(methodArguments );	

				serviceInvoker.callService(gxtToSeamServiceParameter, callback);
			}};
			 GxtToSeamServiceResultPagingReader<ModelData> pagingReader =  new GxtToSeamServiceResultPagingReader<ModelData>();;

			BasePagingLoader<PagingLoadResult<ModelData>> pageLoader =  new  BasePagingLoader<PagingLoadResult<ModelData>>(proxy,pagingReader);
		
		final  ListStore<ModelData> listStore = new ListStore<ModelData>(pageLoader);
		
		
		//((ContentPanel)grid.getParent()).setBottomComponent(toolBar);
		//listStore.getLoader().load();
		List<ColumnConfig> columnConfigs= new ArrayList<ColumnConfig>();
		columnConfigs.add(new ColumnConfig("NAME","NAME",100));
		columnConfigs.add(new ColumnConfig("TITLE","TITLE",100));
		final ColumnModel cm = new ColumnModel(columnConfigs);
		// 需要把toolbar加到面板上
		PagingToolBar toolBar = new PagingToolBar(10);  
		EditorGrid<ModelData> grid = new EditorGrid<ModelData>(listStore,cm);
		grid.setSize(300, 200);
		toolBar.bind(pageLoader);
		toolBar.setShowToolTips(true);
		//grid.setLoadMask(true);
//		final PagingToolBar toolBar = new PagingToolBar(50);  
//		toolBar.bind(loader);  
		Window window= new Window();
		window.setSize(500,200);
		window.setLayout(new FitLayout());
		window.add(grid);
		window.setBottomComponent(toolBar);
		window.show();
		grid.reconfigure(listStore, cm);
		listStore.getLoader().load();
		//grid.reconfigure(listStore, new ColumnModel(new ArrayList<ColumnConfig>()));
		//grid.reconfigure(new ListStore<ModelData>(), null);
		//grid.reconfigure(listStore, cm);
		//listStore.getLoader().load();

	}
	
	private void testOneWindow() {
		/*FormPanel form2 = new FormPanel();   
	    form2.setFrame(true);   
	    form2.setHeading("Simple Form with FieldSets");   
	    form2.setWidth(500);   
	    form2.setLayout(new FlowLayout());   
	    Window w = new Window();        
	    w.setHeading("Product Information");
	    w.setModal(true);
	    w.setSize(600, 400);
	    w.setMaximizable(true);
	    w.setToolTip("The ExtGWT product page...");*/
	    //w.setUrl("http://www.extjs.com/products/gxt");
	   // w.show();
	    
	    ContentPanel left=new ContentPanel();
	    left.setLayout(new FormLayout());
	    TextField<String> textField=new TextField<String>();
	    textField.setFieldLabel("xxx");
	    left.add(textField);
	   // left.setLayout(new ColumnLayout());
	    ContentPanel right=new ContentPanel();
	    TextField<String> textField2=new TextField<String>();
	    textField2.setFieldLabel("8888888");
	    right.add(textField2);
		Window window = new Window();
		ContentPanel contentPanel = new ContentPanel();
		FormPanel formPanel= new FormPanel();
		formPanel.addButton(new Button("mydesktop"));
		//formPanel.show();
		contentPanel.setLayout(new ColumnLayout());
		//contentPanel.add(formPanel);
		contentPanel.add(left, new ColumnData(.5));
		contentPanel.add(right, new ColumnData(.5));
		
		formPanel.add(contentPanel);
		window.setHeading(DESKTOP);
		window.add(formPanel);
	//	window.add(form2);
		window.setSize(800, 300);
		window.setFrame(true);
		window.show();
		//RootPanel.get().add(form2);
		
	}


	/*private ContentPanel createGridSetModule() {
		ContentPanel gridSetModule = GridSetModulesFactory.createGridModule(getGridSetModuleGxtComponentMetaNodeModel());

		Grid<ModelData> grid2 =  null;
		for(Iterator<Component> it = gridSetModule.iterator(); it.hasNext(); ) {
			
			LayoutContainer layoutContainer = (LayoutContainer)it.next();
			for(Iterator<Component> subIt = layoutContainer.iterator(); subIt.hasNext(); ) {
				
				Component subComponent = subIt.next();
				System.err.println("-----------gridPanel-------Child-----------"+subComponent.getClass());
				if (subComponent instanceof Grid) {
					 grid2 = (Grid)subComponent;
				}
				
			} 								
		} 
		//grid2 = null;
			//locateGrid(gridSetModule,grid2);
		final Grid<ModelData> grid = grid2;
		System.err.println(grid+"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXx");
		final GxtToSeamServiceParameter gxtToSeamServiceParameter = grid.getData("gxtToSeamServiceParameter");
		gxtToSeamServiceParameter.setServiceComponentName("com.test.server.business.PersonService");
		gxtToSeamServiceParameter.setServiceMethodName("listPerson2");
		BaseModel[] methodArguments = new BaseModel[1];
		methodArguments[0] = new BaseModel();
		gxtToSeamServiceParameter.setMethodArguments(methodArguments );	
		RpcProxy<GxtToSeamServiceResult> proxy = new RpcProxy<GxtToSeamServiceResult>(){

			@Override
			protected void load(Object loadConfig,
					AsyncCallback<GxtToSeamServiceResult> callback) {
				serviceInvoker.callService(gxtToSeamServiceParameter, callback);
			}};
		  
			GxtToSeamServiceResultListReader<GxtToSeamServiceResult> listReader = new GxtToSeamServiceResultListReader<GxtToSeamServiceResult>();
			BaseListLoader<BaseListLoadResult<ModelData>> loader =  new  BaseListLoader<BaseListLoadResult<ModelData>>(proxy,listReader);

		final  ListStore<ModelData> listStore = new ListStore<ModelData>(loader);
		listStore.getLoader().load();
		final ColumnModel cm = grid.getColumnModel();
		grid.reconfigure(listStore, new ColumnModel(new ArrayList<ColumnConfig>()));
		
		grid.reconfigure(listStore, cm);
		listStore.getLoader().load();
		//return gridSetModule;
		
		final FormPanel formPanel = new FormPanel();
		formPanel.setWidth(600);
		formPanel.setFrame(true);
		
		TextField<String> username = new TextField<String>();
		username.setFieldLabel("用户名");
		username.setName("username");
		username.setEmptyText("abc");
		formPanel.add(username);
		
		TextField<String> password = new TextField<String>();
		password.setFieldLabel("密码");
		password.setName("password");
		password.setPassword(true);
		password.setEmptyText("abc");
		formPanel.add(password);
		formPanel.add(gridSetModule);
		
		CheckBox check1 = new CheckBox();   
	    check1.setBoxLabel("Classical");
	    check1.setName("check1111111");
	    CheckBox check2 = new CheckBox();   
	    check2.setBoxLabel("Rock");   
	    check2.setName("check22222222");
	  
	    CheckBox check3 = new CheckBox();   
	    check3.setBoxLabel("Blue");   
	    check3.setName("check333333333");
	    check3.setValue(true);
	    CheckBoxGroup checkGroup = new CheckBoxGroup();   
	    checkGroup.setFieldLabel("Music");   
	    checkGroup.add(check1);   
	    checkGroup.add(check2);   
	    checkGroup.add(check3);   
	    checkGroup.setName("checkGroup0000");
		formPanel.add(checkGroup);
		
		
		Radio radio = new Radio();   
	    radio.setBoxLabel("Red");   
	    radio.setValue(true);   
	    radio.setName("radio11111111");
	    
	    Radio radio2 = new Radio();   
	    radio2.setBoxLabel("Blue");   
	    radio2.setName("radio222222222");
	    
	    RadioGroup radioGroup = new RadioGroup();   
	    radioGroup.setFieldLabel("Favorite Color");   
	    radioGroup.add(radio);   
	    radioGroup.add(radio2);   
		radioGroup.setName("radioGroup");
	    formPanel.add(radioGroup);
	    
	    TextArea description = new TextArea();   
	    description.setPreventScrollbars(true);   
	    description.setFieldLabel("Description");
	    description.setName("description");
	    formPanel.add(description);
	    
	    ComboBox<ModelData> combo = ComboBoxFactory.createComboBox(getComboBoxGxtComponentMetaNodeModel());   
	    combo.setFieldLabel("Company");   
	   // combo.setDisplayField("name");   
	    combo.setName("comboBox00000000");
	    formPanel.add(combo);
	    //combo.setTriggerAction(TriggerAction.ALL);   
	    //combo.setStore(store);   
	    
		Button button= new Button("summit");
		final ServiceInvokerAsync serviceInvoker = GWT.create(ServiceInvoker.class);

		button.addSelectionListener(new SelectionListener<ButtonEvent>() {

			@Override
			public void componentSelected(ButtonEvent ce) {
				
				
				
						
				
				GxtToSeamServiceParameter gxtToSeamServiceParameter = new GxtToSeamServiceParameter();
				gxtToSeamServiceParameter.setServiceComponentName("com.test.server.business.PersonService");
				gxtToSeamServiceParameter.setServiceMethodName("formSubmint");
				BaseModel[] methodArguments2 = new BaseModel[1];
				methodArguments2[0] = new BaseModel();
				gxtToSeamServiceParameter.setMethodArguments(methodArguments2 );
				
				
				

						ListStore<ModelData> listStore = grid.getStore();
						List<Record> records = listStore.getModifiedRecords();
						List<ModelData> modelDatas = new ArrayList<ModelData>();
						for (Record record : records) {
							ModelData modelData = record.getModel();
							modelDatas.add(modelData);
							//String nameString = modelData.get("name");
							//modelData.get("name");
						}
						if (modelDatas.size()>0) {
							methodArguments2[0].set(grid.getId(), modelDatas);
						}
				
						for (Field<?> field : formPanel.getFields()) {
							System.err.println("*******************************");
							System.err.println(field.getClass());
							if (field instanceof RadioGroup) {
								String name = ((RadioGroup)field).getName();
								String name2 = ((RadioGroup)field).getFieldLabel();
								String value = ((RadioGroup)field).getValue().getName();
								String value2 = ((RadioGroup)field).getValue().getBoxLabel();
								//System.err.println(name+"----------"+value);
								System.err.println(name2+"----------"+value2);
								methodArguments2[0].set(name2, value2);
								
							}else if (field instanceof CheckBoxGroup) {
								String name = ((CheckBoxGroup)field).getName();
								String name2 = ((CheckBoxGroup)field).getFieldLabel();
								List<CheckBox> checkBoxs = ((CheckBoxGroup)field).getValues();
								List<String> values= new ArrayList<String>();
								for (CheckBox checkBox : checkBoxs) {
									values.add(checkBox.getName());
								}
								//System.err.println(name+"----------"+values);
								System.err.println(name2+"----------"+values);
								methodArguments2[0].set(name2, values);


							}else if (field instanceof ComboBox) {
								String name = ((ComboBox)field).getName();
								//String name2 = ((CheckBoxGroup)field).getFieldLabel();
								ModelData modelData = ((ComboBox)field).getValue();
								String value= modelData.get("name");
								
		
								//System.err.println(name+"----------"+values);
								System.err.println(name+"----------"+value);
								methodArguments2[0].set(name, value);
							}
							else if(field.isDirty()) {
								System.out.println(field.getName()+" is dirty");
								methodArguments2[0].set(field.getName(), field.getValue());

							}
							
						}
				serviceInvoker.callService(gxtToSeamServiceParameter , new AsyncCallback<GxtToSeamServiceResult>() {
					
					@Override
					public void onSuccess(GxtToSeamServiceResult result) {
						grid.getStore().commitChanges();
					}
					
					@Override
					public void onFailure(Throwable caught) {
					}
				});
			}
		});
		FormButtonBinding binding=new FormButtonBinding(formPanel);
		 binding.addButton(button);
		formPanel.addButton(button);
		
		Button button2= new Button("reset");
			button2.addSelectionListener(new SelectionListener<ButtonEvent>() {
				
				@Override
				public void componentSelected(ButtonEvent ce) {
					
					List<Field<?>> fields = formPanel.getFields();
					for (Field<?> field : fields) {
						if (field.isDirty()) {
							System.out.println(field.getName()+" is dirty");						
						}
						field.reset();
					}
					
					ListStore<ModelData> listStore = grid.getStore();
					listStore.rejectChanges();
				}
			});
		binding.addButton(button2);
		formPanel.addButton(button2);
		
	
		return formPanel;
	}
	*/
	
	private void locateGrid(Container<Component> gridSetModule,Grid grid) {
		System.err.println(gridSetModule.getClass());
		for (Component component : gridSetModule.getItems()) {
			System.err.println(component.getClass());
			if (component instanceof Grid) {
				if (grid ==null) {
					grid = (Grid)component;
				}
				
				
			}else if(component instanceof Container){
				locateGrid((Container)component,grid);
			}
		}
		
	}

	private GxtComponentMetaNodeModel getComboBoxGxtComponentMetaNodeModel() {
		//入库类别
		Map<String, Object> type = new HashMap<String, Object>();
		type.put("component_model_type_index", ComponentTypeEnum.COMBOBOX_MODEL.ordinal());
		type.put("fieldlabel", "入库类别");
		type.put("dataload", "xxx");
		type.put("allowblank", false);
		GxtComponentMetaNodeModel node11  = new GxtComponentMetaNodeModel(type,12,13);
		return node11;
	}
	
	/*private GxtComponentMetaNodeModel getGridSetModuleGxtComponentMetaNodeModel() {
		Map<String, Object> map2 = new HashMap<String, Object>();
//		map2.put("component_model_type", ComponentTypeEnum.GRIDSETMODULES_MODEL);
		map2.put("component_model_type_index", ComponentTypeEnum.GRIDSETMODULES_MODEL.ordinal());
		//map2.put("autowidth", true);
		map2.put("width", 600);
		map2.put("autoheight", true);
		map2.put("frame", true);
		map2.put("headervisible", false);
		Map<String,Object> oneDispacherEventTypeData = new HashMap<String, Object>();
		EventStructureMetaModel subEventStructureMetaModel = new EventStructureMetaModel();
		subEventStructureMetaModel.setControllerId("dataLoadController01");
		subEventStructureMetaModel.setRootControllerId("windowController");
		oneDispacherEventTypeData.put("eventstructuremetamodel", subEventStructureMetaModel);
		Map<String, Object> oneRegisterEventTypeData = new HashMap<String, Object>();
		oneRegisterEventTypeData .put("dispachereventtype", "0007");
		Map<String, Object> RegisterEventTypeDatas = new HashMap<String, Object>();
		RegisterEventTypeDatas = new HashMap<String, Object>();
		RegisterEventTypeDatas.put("0003", oneRegisterEventTypeData);
		map2.put("registereventtypes", RegisterEventTypeDatas);
		
		Map<String,Object> dispacherEventTypeDatas = new HashMap<String, Object>();
		dispacherEventTypeDatas.put("0007", oneDispacherEventTypeData);
		map2.put("dispachereventtypes", dispacherEventTypeDatas);
			Map<String, Object> map3 = new HashMap<String, Object>();
			
			map3.put("component_model_type", ComponentTypeEnum.GRIDMODULE_MODEL);
			map3.put("version",4);//这个必须放在第一个
			map3.put("hight", 300);
			map3.put("width", 300);
			map3.put("number", 10);
			map3.put("loadernumber", 0);
			map3.put("headervisible",false );
			map3.put("rownumber",false);//这个是不是树形表格必须有的，false代表不带行号，true代表带行号
			GxtComponentMetaNodeModel node3= new GxtComponentMetaNodeModel(map3);
			//分组表格表格
			Map<String, Object> map3 = new HashMap<String, Object>();
			map3.put("component_model_type", ComponentTypeEnum.GRIDMODULE_MODEL);
			map3.put("version",2);//分组表格
			map3.put("hight", 100);
			//map3.put("width", 500);
			map3.put("pagesize", 20);
			map3.put("groupingview", true);
			map3.put("groupingcolumnid", "industry");
			map3.put("headervisible",false );
			map3.put("rownumber", true);
			GxtComponentMetaNodeModel node3 = new GxtComponentMetaNodeModel(map3);
			//可编辑表格
			Map<String, Object> map3 = new HashMap<String, Object>();
			//实际中，此属性不起作用
//			map3.put("component_model_type", ComponentTypeEnum.GRIDMODULE_MODEL);
			map3.put("component_model_type_index", ComponentTypeEnum.GRIDMODULE_MODEL.ordinal());
			map3.put("version",1);//可编辑表格
			map3.put("hight", 100);
			//map3.put("width", 500);
			map3.put("headervisible",false );
			map3.put("rownumber", true);
					List<ModelData> columnConfigs = new ArrayList<ModelData>();		
					columnConfigs.add(new GridColumnConfigModel("name","用户22名222_grid1",100));
					columnConfigs.add(new GridColumnConfigModel("age","年22龄222_grid1",100));
					columnConfigs.add(new GridColumnConfigModel("age","年88龄222_grid1",100));
					
			map3.put("columnconfigload", columnConfigs);
			
					
					
					BaseModel gxtToSeamServiceParameter = new BaseModel();
					gxtToSeamServiceParameter.set("serviceComponentName", "com.test.server.business.PersonService");
					gxtToSeamServiceParameter.set("serviceMethodName", "loadEditorableGrid");
					BaseModel[] methodArguments2 = new BaseModel[1];
					methodArguments2[0] = new BaseModel();
					gxtToSeamServiceParameter.set("methodArguments",methodArguments2 );
			map3.put("gxttoseamserviceparametermodel", gxtToSeamServiceParameter);
			map3.put("dataload", gxtToSeamServiceParameter);
			GxtComponentMetaNodeModel node3 = new GxtComponentMetaNodeModel(map3);
			
			//分页表格
			Map<String, Object> map3 = new HashMap<String, Object>();
			map3.put("component_model_type", ComponentTypeEnum.GRIDMODULE_MODEL);
			map3.put("version",3);//分页表格
			map3.put("hight", 100);
			//map3.put("width", 500);
			map3.put("pagesize", 20);
			//map3.put("number", 10);
			//map3.put("loadernumber", 0);
			map3.put("headervisible",false );
			map3.put("rownumber", true);
			GxtComponentMetaNodeModel node3 = new GxtComponentMetaNodeModel(map3);
		List<GxtComponentMetaNodeModel> list = new ArrayList<GxtComponentMetaNodeModel>();
		list.add(node3);
		map2.put("gridlist", list);
		
		
		
		
							//创建提交和取消按钮
							Map<String, Object> btnSubmit=new HashMap<String, Object>();
					//		btnSubmit.put("component_model_type", ComponentTypeEnum.BUTTON_MODEL);
							//实际创建时，不检查此属性
							btnSubmit.put("component_model_type_index", ComponentTypeEnum.BUTTON_MODEL.ordinal());
							btnSubmit.put("text", "sumFormPanel确定");
							
							Map<String,Object> codes2 = new HashMap<String, Object>();
							//添加需要监听的事件类型，指定由某一个控制器响应，控制器内部应该如何响应（附加参数和数据）
							*//**
							 * 00_01_02为特征码
							 * 或者是 控制器的唯一标识
							 *//*
									Map<String,Object> oneRegisterEventTypeData = new HashMap<String, Object>();
										EventStructureMetaModel eventStructureMetaModel = new EventStructureMetaModel();
										//eventStructureMetaModel.setControllerId("shortcutController02");
										eventStructureMetaModel.setRootControllerId("windowController2");
										//eventStructureMetaModel.setResponseModeId("00_02_02");
									oneRegisterEventTypeData.put("eventstructuremetamodel", eventStructureMetaModel);
									oneRegisterEventTypeData.put("dispachereventtype", "0007");
							
								codes2.put("0302", oneRegisterEventTypeData);
							btnSubmit.put("registereventtypes", codes2);
							GxtComponentMetaNodeModel btnSubmit1=new GxtComponentMetaNodeModel(btnSubmit);
							
							Map<String, Object> btnquxiao=new HashMap<String, Object>();
					//		btnquxiao.put("component_model_type", ComponentTypeEnum.BUTTON_MODEL);
							//实际创建时，不检查此属性
							btnquxiao.put("component_model_type_index", ComponentTypeEnum.BUTTON_MODEL.ordinal());
							btnquxiao.put("text", "取消");
							GxtComponentMetaNodeModel btn1=new GxtComponentMetaNodeModel(btnquxiao);
							
							List<GxtComponentMetaNodeModel> list1=new ArrayList<GxtComponentMetaNodeModel>();
							list1.add(btnSubmit1);
							list1.add(btn1);
					
		map2.put("addbutton", list1);
		GxtComponentMetaNodeModel node2 = new GxtComponentMetaNodeModel(map2);
		return node2;
	}

*/
	
	
	private FormPanel getFormPaenlSubmit(){
		//NamedFrame resultPanel = new NamedFrame("_self");
		final FormPanel panel = new FormPanel();		
		panel.setHeading("File Upload Example");   
	    panel.setFrame(true);   
	   // panel.setAction("myurl");   
	   // panel.setEncoding(Encoding.MULTIPART);   
	   // panel.setMethod(Method.POST);   
	    panel.setButtonAlign(HorizontalAlignment.CENTER);   
	    panel.setWidth(350);  
		//FormLayout layout = new FormLayout();
		//panel.setLayout(layout);
		
		
		TextField<String> username = new TextField<String>();
		username.setFieldLabel("用户名");
		username.setName("username");
		username.setEmptyText("abc");
		panel.add(username);
		
		TextField<String> password = new TextField<String>();
		password.setFieldLabel("密码");
		password.setName("password");
		password.setPassword(true);
		password.setEmptyText("abc");
		panel.add(password);
		panel.setAction(GWT.getModuleBaseURL()+"register");
		panel.setEncoding(Encoding.URLENCODED);
		panel.setMethod(Method.GET);
		
		Button button= new Button("summit");
		final ServiceInvokerAsync serviceInvoker = GWT.create(ServiceInvoker.class);

		button.addSelectionListener(new SelectionListener<ButtonEvent>() {

			@Override
			public void componentSelected(ButtonEvent ce) {
						GxtToSeamServiceParameter gxtToSeamServiceParameter = new GxtToSeamServiceParameter();
						gxtToSeamServiceParameter.setServiceComponentName("com.test.server.business.PersonService");
						gxtToSeamServiceParameter.setServiceMethodName("formSubmint");
						BaseModel[] methodArguments2 = new BaseModel[1];
						methodArguments2[0] = new BaseModel();
//						gxtToSeamServiceParameter.setMethodArguments(methodArguments2 );				
				
				List<Field<?>> fields = panel.getFields();
				//TODO 控制哪些Field向后台提交数据
				System.err.println("*******************************");
				System.out.println("panel.getFields()");
				for (Field<?> field : fields) {
					
					if (field.isDirty()) {
						System.out.println(field.getName()+" is dirty");
						methodArguments2[0].set(field.getName(), field.getValue());

					}
					System.out.println("field.getName() "+field.getName());
					System.out.println("field.getValue() "+field.getValue());
					
					System.err.println("*******************************");
				}
				//panel.submit();
				serviceInvoker.callService(gxtToSeamServiceParameter , new AsyncCallback<GxtToSeamServiceResult>() {
					
					@Override
					public void onSuccess(GxtToSeamServiceResult result) {
					}
					
					@Override
					public void onFailure(Throwable caught) {
					}
				});
			}
		});
		FormButtonBinding binding=new FormButtonBinding(panel);
		 binding.addButton(button);
		panel.addButton(button);
		
		Button button2= new Button("reset");
			button2.addSelectionListener(new SelectionListener<ButtonEvent>() {
				
				@Override
				public void componentSelected(ButtonEvent ce) {
					//换成MessageBox
					//MessageBox.info("Action", "You file was uploaded", null);   
					List<Field<?>> fields = panel.getFields();
					for (Field<?> field : fields) {
						if (field.isDirty()) {
							System.out.println(field.getName()+" is dirty");
							field.reset();
						}
						
					}
				}
			});
		binding.addButton(button2);
		panel.addButton(button2);
		
		
		
		final FormPanel panel2 = new FormPanel();		
		panel2.setHeading("File Upload Example");   
	    panel2.setFrame(true);   
		return panel;
	}
	
	
	
	private void createDynamicDesktop() {
		
		
	}

	public void testMvc() {
		 Dispatcher dispatcher = Dispatcher.get();
		 dispatcher.addController(new LoginController());
//		 dispatcher.addController(new DesktopController());
		
		 		/*WindowController windowControler = new WindowController();
		 		PanelControler panelControler = new PanelControler();
		 		RadioGroupControler textFieldControler = new RadioGroupControler();
		 		
		 		windowControler.addChild(panelControler);
		 		panelControler.addChild(textFieldControler);
		 		panelControler.addChild(new RadioGroupControler());*/
		 		
		 //dispatcher.addController(new WindowManagementController());
		    /*dispatcher.addController(new AppController());
		    dispatcher.addController(new MailController());
		    dispatcher.addController(new TaskController());
		    dispatcher.addController(new ContactController());*/
		    
		    //ֻ��AppController��Ӧ��ǰAppEvents.Login�¼�
		    dispatcher.dispatch(AppEvents.DESKTOP_USER_LOGIN);
	}
	
	
	 /**
	 * 动态创建树形控制器----窗口相关
	 */
	private Controller createDynamicController3() {
		Map<String , Object> windowController=new HashMap<String, Object>();
		windowController.put("component_controller_model_type", ComponentControllerEnum.WINDOW_CONTROLLER_MODEL);
		List<String> codes1 = new ArrayList<String>();
		codes1.add("0101");
		codes1.add("0301");		
		codes1.add("0003");
		codes1.add("0201");
		//codes1.add("0005");
		codes1.add("0007");
		codes1.add("0008");
		
		windowController.put("id", "windowController");
		windowController.put("registereventtypes", codes1);
		windowController.put("viewdata", "window_viewData_init_01");		
		GxtComponentMetaNodeModel node=new GxtComponentMetaNodeModel(windowController,1,14);
		
		Map<String , Object> contentPanelController=new HashMap<String, Object>();
		contentPanelController.put("component_controller_model_type", ComponentControllerEnum.CONTENTPANEL_CONTROLLER_MODEL);
		List<String> codes2 = new ArrayList<String>();
		codes2.add("0201");
		codes2.add("0301");
		codes2.add("0101");
		codes2.add("0007");
		codes2.add("0008");
		contentPanelController.put("registereventtypes", codes2);				
		contentPanelController.put("id", "contentPanelController");				
		contentPanelController.put("viewdata", "contentPanel_viewData_init_01");		
		GxtComponentMetaNodeModel node2=new GxtComponentMetaNodeModel(contentPanelController,2,13);
		
		Map<String , Object> menuBarController=new HashMap<String, Object>();
		menuBarController.put("component_controller_model_type", ComponentControllerEnum.MENUBAR_CONTROLLER_MODEL);
		List<String> codes3 = new ArrayList<String>();
		codes3.add("0201");
		codes3.add("0301");
		codes3.add("0101");
		codes3.add("0007");
		codes3.add("0008");
		menuBarController.put("registereventtypes", codes3);
		menuBarController.put("id", "menuBarController");
		menuBarController.put("viewdata", "menuBar_viewData_init_01");		
		GxtComponentMetaNodeModel node3=new GxtComponentMetaNodeModel(menuBarController,3,4);
		
		Map<String , Object> toolBarController=new HashMap<String, Object>();
		toolBarController.put("component_controller_model_type", ComponentControllerEnum.TOOLBAR_CONTROLLER_MODEL);
		List<String> codes4 = new ArrayList<String>();
		codes4.add("0201");
		codes4.add("0301");
		codes4.add("0101");
		codes4.add("0007");
		codes4.add("0008");
		toolBarController.put("registereventtypes", codes4);
		toolBarController.put("id", "toolBarController");
		toolBarController.put("viewdata", "toolBar_viewData_init_01");		
		GxtComponentMetaNodeModel node4=new GxtComponentMetaNodeModel(toolBarController,5,6);
		
		//创建提交和取消按钮
		Map<String, Object> btnSubmit=new HashMap<String, Object>();
		btnSubmit.put("component_model_type", ComponentTypeEnum.BUTTON_MODEL);
		btnSubmit.put("text", "确定");
		GxtComponentMetaNodeModel btnSubmit1=new GxtComponentMetaNodeModel(btnSubmit);
		
		Map<String, Object> btnquxiao=new HashMap<String, Object>();
		btnquxiao.put("component_model_type", ComponentTypeEnum.BUTTON_MODEL);
		btnquxiao.put("text", "取消");
		GxtComponentMetaNodeModel btn1=new GxtComponentMetaNodeModel(btnquxiao);
		
		List<GxtComponentMetaNodeModel> list1=new ArrayList<GxtComponentMetaNodeModel>();
		list1.add(btnSubmit1);
		list1.add(btn1);
		Map<String, Object> sumFormPanelController=new HashMap<String, Object>();
		List<String> codes45 = new ArrayList<String>();
		codes45.add("0201");
		codes45.add("0301");
		codes45.add("0101");
		codes45.add("0007");
		codes45.add("0008");
		sumFormPanelController.put("registereventtypes", codes45);
		sumFormPanelController.put("id", "sumFormPanelController");
		sumFormPanelController.put("controllerdata", "sumFormPanel_controllerdata_init_01");		
		sumFormPanelController.put("viewdata", "sumFormPanel_viewData_init_01");		
		GxtComponentMetaNodeModel node45=new GxtComponentMetaNodeModel(sumFormPanelController, 7, 12);
		
		
		Map<String , Object> formPanelController=new HashMap<String, Object>();
		formPanelController.put("component_controller_model_type", ComponentControllerEnum.FORMSET_MODULE_CONTROLLER_MODEL);
		List<String> codes5 = new ArrayList<String>();
		codes5.add("0201");
		codes5.add("0301");
		codes5.add("0101");
		codes5.add("0007");
		codes5.add("0008");
		formPanelController.put("registereventtypes", codes5);
		formPanelController.put("id", "formPanelController");
		formPanelController.put("controllerdata", "formPanel_controllerdata_init_01");		
		formPanelController.put("viewdata", "formPanel_viewData_init_01");		
		GxtComponentMetaNodeModel node5=new GxtComponentMetaNodeModel(formPanelController,8,9);
		
		Map<String , Object> textFieldController=new HashMap<String, Object>();
		textFieldController.put("component_controller_model_type", ComponentControllerEnum.GRID_CONTROLLER_MODEL);
		List<String> codes6 = new ArrayList<String>();
		codes6.add("0301"); 
		codes6.add("0201"); 
		codes6.add("0101");
		codes6.add("0007");
		codes6.add("0008");
		textFieldController.put("registereventtypes", codes6);
		textFieldController.put("id", "textFieldController");
		textFieldController.put("viewdata", "textField_viewData_init_01");		
		GxtComponentMetaNodeModel node6=new GxtComponentMetaNodeModel(textFieldController,10,11);
		
		/*Map<String , Object> textFieldController=new HashMap<String, Object>();
		textFieldController.put("component_controller_model_type", ComponentControllerEnum.TEXTFIELD_CONTROLLER_MODEL);
		List<String> codes6 = new ArrayList<String>();
		codes6.add("0301"); 
		codes6.add("0201"); 
		codes6.add("0101");
		codes6.add("0007");
		codes6.add("0008");
		textFieldController.put("registereventtypes", codes6);
		textFieldController.put("id", "textFieldController");
		textFieldController.put("viewdata", "textField_viewData_init_01");		
		GxtComponentMetaNodeModel node6=new GxtComponentMetaNodeModel(textFieldController,8,9);*/
		
		/*Map<String , Object> comboBoxController=new HashMap<String, Object>();
		comboBoxController.put("component_controller_model_type", ComponentControllerEnum.COMBOBOX_CONTROLLER_MODEL);
		List<String> codes6 = new ArrayList<String>();
		codes6.add("0301"); 
		codes6.add("0201"); 
		codes6.add("0101");
		codes6.add("0007");
		codes6.add("0008");
		comboBoxController.put("registereventtypes", codes6);
		comboBoxController.put("id", "textFieldController");
		comboBoxController.put("viewdata", "textField_viewData_init_01");		
		GxtComponentMetaNodeModel node6=new GxtComponentMetaNodeModel(comboBoxController,8,9);*/
		
		/*Map<String , Object> dateFieldController=new HashMap<String, Object>();
		dateFieldController.put("component_controller_model_type", ComponentControllerEnum.DATEFIELD_CONTROLLER_MODEL);
		List<String> codes6 = new ArrayList<String>();
		codes6.add("0301"); 
		codes6.add("0201"); 
		codes6.add("0101");
		codes6.add("0007");
		codes6.add("0008");
		dateFieldController.put("registereventtypes", codes6);
		dateFieldController.put("id", "textFieldController");
		dateFieldController.put("viewdata", "textField_viewData_init_01");		
		GxtComponentMetaNodeModel node6=new GxtComponentMetaNodeModel(dateFieldController,8,9);*/

		List<GxtComponentMetaNodeModel> list=new ArrayList<GxtComponentMetaNodeModel>();
		list.add(node);
		list.add(node2);
		list.add(node3);
		list.add(node4);
		list.add(node5);
		list.add(node6);
		GxtComponentMetaModel gxtComponentMetaModel=new GxtComponentMetaModel(list);
//		return GxtComponentControlerFactory.createGxtComponentController(gxtComponentMetaModel);
		return null;
		
	}
	
	
	/**
	 动态创建树形控制	 
	 树状Controller确定以后，就相当于确定了最终要生成的视图界面
	 shortcutController.put("viewData", ??);	
	 viewData 对应的数据为32bit uuid
	 */
	public Controller createDynamicController2() {
		Map<String , Object> desktopController=new HashMap<String, Object>();
		desktopController.put("component_controller_model_type", ComponentControllerEnum.DESKTOP_CONTROLLOR_MODEL);
		List<String> codes1 = new ArrayList<String>();
		codes1.add("0003");
		codes1.add("0002");
		codes1.add("0005");
		desktopController.put("registereventtypes", codes1);
		desktopController.put("id", "desktopController");
		GxtComponentMetaNodeModel node=new GxtComponentMetaNodeModel(desktopController,1,14);
		
		Map<String , Object> shortcutController=new HashMap<String, Object>();
		shortcutController.put("component_controller_model_type", ComponentControllerEnum.SHORTCUT_CONTROLLER_MODEL);
		List<String> codes2 = new ArrayList<String>();
		codes2.add("0003");
		codes2.add("0002");
		codes2.add("0005");
		shortcutController.put("registereventtypes", codes2);
		shortcutController.put("id", "shortcutController01");
		shortcutController.put("viewdata", "shortcut_viewData_init_01");		
		GxtComponentMetaNodeModel node2=new GxtComponentMetaNodeModel(shortcutController,2,3);
		
		Map<String , Object> shortcutController2=new HashMap<String, Object>();
		shortcutController2.put("component_controller_model_type", ComponentControllerEnum.SHORTCUT_CONTROLLER_MODEL);
		List<String> codes22 = new ArrayList<String>();
		codes22.add("0003");
		codes22.add("0002");
		codes22.add("0005");
		shortcutController2.put("registereventtypes", codes22);
		shortcutController2.put("id", "shortcutController02");
		shortcutController2.put("viewdata", "shortcut_viewData_init_02");		
		GxtComponentMetaNodeModel node22=new GxtComponentMetaNodeModel(shortcutController2,4,5);
		
		Map<String , Object> desktopMeunItemController=new HashMap<String, Object>();
		desktopMeunItemController.put("component_controller_model_type", ComponentControllerEnum.DESKTOP_MENUITEM_CONTROLLER_MODEL);
		List<String> codes3 = new ArrayList<String>();
		codes3.add("0003");
		codes3.add("0002");
		codes3.add("0005");
		desktopMeunItemController.put("registereventtypes", codes3);
		desktopMeunItemController.put("id", "desktopMeunItemController01");
		desktopMeunItemController.put("viewdata", "desktopmenuitem_viewData_init_01");		
		GxtComponentMetaNodeModel node3=new GxtComponentMetaNodeModel(desktopMeunItemController,6,7);
		
		
		Map<String , Object> desktopMeunItemController2=new HashMap<String, Object>();
		desktopMeunItemController2.put("component_controller_model_type", ComponentControllerEnum.DESKTOP_MENUITEM_CONTROLLER_MODEL);
		List<String> codes32 = new ArrayList<String>();
		codes32.add("0003");
		codes32.add("0002");
		codes32.add("0005");
		desktopMeunItemController2.put("registereventtypes", codes32);
		desktopMeunItemController2.put("id", "desktopMeunItemController02");
		desktopMeunItemController2.put("viewdata", "desktopmenuitem_viewData_init_02");		
		GxtComponentMetaNodeModel node32=new GxtComponentMetaNodeModel(desktopMeunItemController2,8,9);
		
		Map<String , Object> desktopStartMenuController=new HashMap<String, Object>();
		desktopStartMenuController.put("component_controller_model_type", ComponentControllerEnum.DESKTOP_STARTMENU_CONTROLLER_MODEL);
		List<String> codes4 = new ArrayList<String>();
		codes4.add("0003");
		codes4.add("0002");
		codes4.add("0005");
		desktopStartMenuController.put("registereventtypes", codes4);
		desktopStartMenuController.put("id", "desktopStartMenuController01");
		desktopStartMenuController.put("viewdata", "desktopStartMenu_viewData_init_01");		
		GxtComponentMetaNodeModel node4=new GxtComponentMetaNodeModel(desktopStartMenuController,10,11);
		
		Map<String , Object> desktopStartMenuController2=new HashMap<String, Object>();
		desktopStartMenuController2.put("component_controller_model_type", ComponentControllerEnum.DESKTOP_STARTMENU_CONTROLLER_MODEL);
		List<String> codes42 = new ArrayList<String>();
		codes42.add("0003");
		codes42.add("0002");
		codes42.add("0005");
		desktopStartMenuController2.put("registereventtypes", codes42);
		desktopStartMenuController2.put("id", "desktopStartMenuController02");
		desktopStartMenuController2.put("viewdata", "desktopStartMenu_viewData_init_02");		
		GxtComponentMetaNodeModel node42=new GxtComponentMetaNodeModel(desktopStartMenuController2,12,13);

		
		List<GxtComponentMetaNodeModel> list=new ArrayList<GxtComponentMetaNodeModel>();
		list.add(node);
		list.add(node2);
		list.add(node22);
		list.add(node3);		
		list.add(node32);		
		list.add(node4);		
		list.add(node42);		
		GxtComponentMetaModel gxtComponentMetaModel=new GxtComponentMetaModel(list);
//		return GxtComponentControlerFactory.createGxtComponentController(gxtComponentMetaModel);
		return null;
		
	}
	
	/**
	 * 动态创建树形控制器----窗口相关
	 */
	public Controller createDynamicController() {
		Map<String , Object> windowController=new HashMap<String, Object>();
		windowController.put("component_controller_model_type", ComponentControllerEnum.WINDOW_CONTROLLER_MODEL);
		List<String> codes1 = new ArrayList<String>();
		codes1.add("0101");
		codes1.add("0301");		
		codes1.add("0003");
		codes1.add("0201");
		//codes1.add("0005");
		codes1.add("0007");
		codes1.add("0008");
		
		windowController.put("id", "windowController");
		windowController.put("registereventtypes", codes1);
		windowController.put("viewdata", "window_viewData_init_01");		
		GxtComponentMetaNodeModel node=new GxtComponentMetaNodeModel(windowController,1,12);
		
		Map<String , Object> contentPanelController=new HashMap<String, Object>();
		contentPanelController.put("component_controller_model_type", ComponentControllerEnum.CONTENTPANEL_CONTROLLER_MODEL);
		List<String> codes2 = new ArrayList<String>();
		codes2.add("0201");
		codes2.add("0301");
		codes2.add("0101");
		codes2.add("0007");
		codes2.add("0008");
		contentPanelController.put("registereventtypes", codes2);				
		contentPanelController.put("id", "contentPanelController");				
		contentPanelController.put("viewdata", "contentPanel_viewData_init_01");		
		GxtComponentMetaNodeModel node2=new GxtComponentMetaNodeModel(contentPanelController,2,11);
		
		Map<String , Object> menuBarController=new HashMap<String, Object>();
		menuBarController.put("component_controller_model_type", ComponentControllerEnum.MENUBAR_CONTROLLER_MODEL);
		List<String> codes3 = new ArrayList<String>();
		codes3.add("0201");
		codes3.add("0301");
		codes3.add("0101");
		codes3.add("0007");
		codes3.add("0008");
		menuBarController.put("registereventtypes", codes3);
		menuBarController.put("id", "menuBarController");
		menuBarController.put("viewdata", "menuBar_viewData_init_01");		
		GxtComponentMetaNodeModel node3=new GxtComponentMetaNodeModel(menuBarController,3,4);
		
		Map<String , Object> toolBarController=new HashMap<String, Object>();
		toolBarController.put("component_controller_model_type", ComponentControllerEnum.TOOLBAR_CONTROLLER_MODEL);
		List<String> codes4 = new ArrayList<String>();
		codes4.add("0201");
		codes4.add("0301");
		codes4.add("0101");
		codes4.add("0007");
		codes4.add("0008");
		toolBarController.put("registereventtypes", codes4);
		toolBarController.put("id", "toolBarController");
		toolBarController.put("viewdata", "toolBar_viewData_init_01");		
		GxtComponentMetaNodeModel node4=new GxtComponentMetaNodeModel(toolBarController,5,6);
		
		Map<String , Object> formPanelController=new HashMap<String, Object>();
		formPanelController.put("component_controller_model_type", ComponentControllerEnum.FORMSET_MODULE_CONTROLLER_MODEL);
		List<String> codes5 = new ArrayList<String>();
		codes5.add("0201");
		codes5.add("0301");
		codes5.add("0101");
		codes5.add("0007");
		codes5.add("0008");
		formPanelController.put("registereventtypes", codes5);
		formPanelController.put("id", "formPanelController");
		formPanelController.put("controllerdata", "formPanel_controllerdata_init_01");		
		formPanelController.put("viewdata", "formPanel_viewData_init_01");		
		GxtComponentMetaNodeModel node5=new GxtComponentMetaNodeModel(formPanelController,7,10);
		
		Map<String , Object> textFieldController=new HashMap<String, Object>();
		textFieldController.put("component_controller_model_type", ComponentControllerEnum.TEXTFIELD_CONTROLLER_MODEL);
		List<String> codes6 = new ArrayList<String>();
		codes6.add("0301"); 
		codes6.add("0201"); 
		codes6.add("0101");
		codes6.add("0007");
		codes6.add("0008");
		textFieldController.put("registereventtypes", codes6);
		textFieldController.put("id", "textFieldController");
		textFieldController.put("viewdata", "textField_viewData_init_01");		
		GxtComponentMetaNodeModel node6=new GxtComponentMetaNodeModel(textFieldController,8,9);
		
		/*Map<String , Object> comboBoxController=new HashMap<String, Object>();
		comboBoxController.put("component_controller_model_type", ComponentControllerEnum.COMBOBOX_CONTROLLER_MODEL);
		List<String> codes6 = new ArrayList<String>();
		codes6.add("0301"); 
		codes6.add("0201"); 
		codes6.add("0101");
		codes6.add("0007");
		codes6.add("0008");
		comboBoxController.put("registereventtypes", codes6);
		comboBoxController.put("id", "textFieldController");
		comboBoxController.put("viewdata", "textField_viewData_init_01");		
		GxtComponentMetaNodeModel node6=new GxtComponentMetaNodeModel(comboBoxController,8,9);*/
		
		/*Map<String , Object> dateFieldController=new HashMap<String, Object>();
		dateFieldController.put("component_controller_model_type", ComponentControllerEnum.DATEFIELD_CONTROLLER_MODEL);
		List<String> codes6 = new ArrayList<String>();
		codes6.add("0301"); 
		codes6.add("0201"); 
		codes6.add("0101");
		codes6.add("0007");
		codes6.add("0008");
		dateFieldController.put("registereventtypes", codes6);
		dateFieldController.put("id", "textFieldController");
		dateFieldController.put("viewdata", "textField_viewData_init_01");		
		GxtComponentMetaNodeModel node6=new GxtComponentMetaNodeModel(dateFieldController,8,9);*/

		List<GxtComponentMetaNodeModel> list=new ArrayList<GxtComponentMetaNodeModel>();
		list.add(node);
		list.add(node2);
		list.add(node3);
		list.add(node4);
		list.add(node5);
		list.add(node6);
		GxtComponentMetaModel gxtComponentMetaModel=new GxtComponentMetaModel(list);
//		return GxtComponentControlerFactory.createGxtComponentController(gxtComponentMetaModel);
		return null;
		
	}
	
	/*public void createDynamicDesktop() {
		SelectionListener<MenuEvent> menuListener = new SelectionListener<MenuEvent>() {
		      @Override
		      public void componentSelected(MenuEvent me) {
		        itemSelected(me);
		      }
		    };
		
		SelectionListener<ComponentEvent> shortcutListener = new SelectionListener<ComponentEvent>() {
		      @Override
		      public void componentSelected(ComponentEvent ce) {
		        itemSelected(ce);
		      }
		    };
		    
		    Window gridWindow = createGridWindow();
		    Shortcut s1 = new Shortcut();
		    s1.setText("Grid Window");
		    s1.setId("grid-win-shortcut");
		    s1.setData("window", gridWindow);
		    s1.addSelectionListener(shortcutListener);
		    //添加一个快捷方式
		    desktop.addShortcut(s1);
		
		 Window accordionWindow = createAccordionWindow();
		Shortcut s2 = new Shortcut();
	    s2.setText("Accordion Window");
	    s2.setId("acc-win-shortcut");
	    s2.setData("window", accordionWindow);
	    s2.addSelectionListener(shortcutListener);
	    //为桌面添加快捷方式
	    desktop.addShortcut(s2);
	    
	    Shortcut shortcut = new Shortcut();
	    shortcut.setText("MyAccordionWindow");
//	    shortcut.setData("window", this.createMyAccordionWindow());
	    shortcut.setData("window", this.getDynamiCaiGouPlan());
	    shortcut.setIconStyle("user");
	    shortcut.addSelectionListener(shortcutListener);
	    //为桌面添加我定义的快捷方式
	    desktop.addShortcut(shortcut);
	    
		 TaskBar taskBar = desktop.getTaskBar();
		 StartMenu startMenu = taskBar.getStartMenu();
		 startMenu.setIconStyle("user");
		 startMenu.setHeading("The StartMenu");
		 
		 MenuItem menuItem = new MenuItem();
		 menuItem.setText("accordinWindow");
		 menuItem.setTitle("title");
		 menuItem.setIcon(IconHelper.createStyle("accordion"));
		 menuItem.setData("window", this.getDynamiCaiGouPlan());
		 menuItem.addSelectionListener(menuListener);
		 startMenu.add(menuItem);
	}
	*/
	
	/**
	 * @return
	 */
	private Window createMyAccordionWindow() {
		Window window = new Window();
		window.setSize(400, 300);
		window.setClosable(true);
		window.setMaximizable(true);
		window.setMinimizable(true);
		window.setHeading("myAccordionWindow");
		AccordionLayout layout = new AccordionLayout();
		window.setLayout(layout);
		//window.show();
		
			Button button = new Button();
			button.setText("按钮1");
			button.setIconStyle("icon-user-add");
			ToolBar toolBar = new ToolBar();
			toolBar.add(button);
			toolBar.add(new SeparatorToolItem());
			Button button2 = new Button();
			//button.setText("按钮1");
			button2.setIconStyle("icon-user-delete");
			button2.setTitle("提示。。。。。。。");
			toolBar.add(button2);
		window.setTopComponent(toolBar);
			ContentPanel tree = new ContentPanel();
			tree.setScrollMode(Scroll.AUTO);
			tree.setHeading("show tree");
			tree.getHeader().addTool(new ToolButton("x-tool-refresh"));
			TreeStore<ModelData> treeStore = new TreeStore<ModelData>();
			ModelData parentData = this.createModelDataWithIcon("family", null);
			ModelData childData = this.createModelDataWithIcon("asdfoasdf", "user");
			ModelData childData2 = this.createModelDataWithIcon("asdfds", "user");
			ModelData childData3 = this.createModelDataWithIcon("wontw", "user");
			ModelData childData4 = this.createModelDataWithIcon("wontw", "user");
			ModelData childData5 = this.createModelDataWithIcon("wontw", "user");
			
			treeStore.add(parentData, false);
			treeStore.add(parentData, childData, false);
			treeStore.add(parentData, childData2, false);
			treeStore.add(parentData, childData3, false);
			treeStore.add(parentData, childData4, false);
			treeStore.add(parentData, childData5, false);
			
			TreePanel<ModelData> treePanel = new TreePanel<ModelData>(treeStore);
			treePanel.setIconProvider(new ModelIconProvider<ModelData>() {

				@Override
				public AbstractImagePrototype getIcon(ModelData model) {
					
					if(model.get("iconStyle")!=null){
						return  IconHelper.createStyle((String)model.get("iconStyle"));
					}
					return null;
				}
			});
			treePanel.setDisplayProperty("name");
			tree.add(treePanel);
		window.add(tree);
			ContentPanel subPanel = new ContentPanel();
			subPanel.addText("xxxxxxxxx");
		window.add(subPanel);
			ContentPanel subPanel2 = new ContentPanel();
			subPanel2.addText("xxxxxxxxx");
		window.add(subPanel2);
		return window;
	}
	 
	 private Window createAccordionWindow() {
		    final Window w = new Window();
		    w.setMinimizable(true);
		    w.setMaximizable(true);
		    w.setIcon(IconHelper.createStyle("accordion"));
		    w.setHeading("Accordion Window");
		    w.setWidth(200);
		    w.setHeight(350);

		    ToolBar toolBar = new ToolBar();
		    Button item = new Button();
		    item.setIcon(IconHelper.createStyle("icon-connect"));
		    toolBar.add(item);

		    toolBar.add(new SeparatorToolItem());
		    w.setTopComponent(toolBar);

		    item = new Button();
		    item.setIcon(IconHelper.createStyle("icon-user-add"));
		    toolBar.add(item);

		    item = new Button();
		    item.setIcon(IconHelper.createStyle("icon-user-delete"));
		    toolBar.add(item);

		    w.setLayout(new AccordionLayout());

		    ContentPanel cp = new ContentPanel();
		    cp.setAnimCollapse(false);
		    cp.setHeading("Online Users");
		    cp.setScrollMode(Scroll.AUTO);
		    cp.getHeader().addTool(new ToolButton("x-tool-refresh"));

		    w.add(cp);

		    TreeStore<ModelData> store = new TreeStore<ModelData>();
		    TreePanel<ModelData> tree = new TreePanel<ModelData>(store);
		    tree.setIconProvider(new ModelIconProvider<ModelData>() {

		      public AbstractImagePrototype getIcon(ModelData model) {
		        if (model.get("icon") != null) {
		          return IconHelper.createStyle((String) model.get("icon"));
		        } else {
		          return null;
		        }
		      }

		    });
		    tree.setDisplayProperty("name");

		    ModelData m = newItem("Family", null);
		    store.add(m, false);
		    tree.setExpanded(m, true);

		    store.add(m, newItem("Darrell", "user"), false);
		    store.add(m, newItem("Maro", "user-girl"), false);
		    store.add(m, newItem("Lia", "user-kid"), false);
		    store.add(m, newItem("Alec", "user-kid"), false);
		    store.add(m, newItem("Andrew", "user-kid"), false);

		    m = newItem("Friends", null);
		    store.add(m, false);
		    tree.setExpanded(m, true);
		    store.add(m, newItem("Bob", "user"), false);
		    store.add(m, newItem("Mary", "user-girl"), false);
		    store.add(m, newItem("Sally", "user-girl"), false);
		    store.add(m, newItem("Jack", "user"), false);

		    cp.add(tree);

		    cp = new ContentPanel();
		    cp.setAnimCollapse(false);
		    cp.setHeading("Settings");
		    cp.setBodyStyleName("pad-text");
		    cp.addText(TestData.DUMMY_TEXT_SHORT);
		    w.add(cp);

		    cp = new ContentPanel();
		    cp.setAnimCollapse(false);
		    cp.setHeading("Stuff");
		    cp.setBodyStyleName("pad-text");
		    cp.addText(TestData.DUMMY_TEXT_SHORT);
		    w.add(cp);

		    cp = new ContentPanel();
		    cp.setAnimCollapse(false);
		    cp.setHeading("More Stuff");
		    cp.setBodyStyleName("pad-text");
		    cp.addText(TestData.DUMMY_TEXT_SHORT);
		    w.add(cp);
		    return w;
		  }
	 private Window createGridWindow() {
		    Window w = new Window();
		    w.setIcon(IconHelper.createStyle("icon-grid"));
		    w.setMinimizable(true);
		    w.setMaximizable(true);
		    w.setHeading("Grid Window");
		    w.setSize(500, 400);
		    w.setLayout(new FitLayout());

		    GroupingStore<Stock> store = new GroupingStore<Stock>();
		    store.add(TestData.getCompanies());
		    store.groupBy("industry");

		    ColumnConfig company = new ColumnConfig("name", "Company", 60);
		    ColumnConfig price = new ColumnConfig("open", "Price", 20);
		    price.setNumberFormat(NumberFormat.getCurrencyFormat());
		    ColumnConfig change = new ColumnConfig("change", "Change", 20);
		    ColumnConfig industry = new ColumnConfig("industry", "Industry", 20);
		    ColumnConfig last = new ColumnConfig("date", "Last Updated", 20);
		    last.setDateTimeFormat(DateTimeFormat.getFormat("MM/dd/y"));

		    List<ColumnConfig> config = new ArrayList<ColumnConfig>();
		    config.add(company);
		    config.add(price);
		    config.add(change);
		    config.add(industry);
		    config.add(last);

		    final ColumnModel cm = new ColumnModel(config);

		    GroupingView view = new GroupingView();
		    view.setForceFit(true);
		    view.setGroupRenderer(new GridGroupRenderer() {
		      public String render(GroupColumnData data) {
		        String f = cm.getColumnById(data.field).getHeader();
		        String l = data.models.size() == 1 ? "Item" : "Items";
		        return f + ": " + data.group + " (" + data.models.size() + " " + l + ")";
		      }
		    });

		    Grid<Stock> grid = new Grid<Stock>(store, cm);
		    grid.setView(view);
		    grid.setBorders(true);

		    w.add(grid);
		    return w;
		  }
	 
	 private ModelData newItem(String text, String iconStyle) {
		    ModelData m = new BaseModelData();
		    m.set("name", text);
		    m.set("icon", iconStyle);
		    return m;
		  }
	 
	 
	 private ModelData createModelDataWithIcon(String name,String iconStyle) {
		ModelData modelData = new BaseModelData();
		modelData.set("name", name);
		modelData.set("iconStyle", iconStyle);
		return modelData;
	}
	/* private void itemSelected(ComponentEvent ce) {
		    Window w;
		    
		    if (ce instanceof MenuEvent) {//当ce是菜单触发的事件
		      MenuEvent me = (MenuEvent) ce;
		    //s1.setData("window", gridWindow);
		      //创建并加载窗口对象
		      w = me.getItem().getData("window");
		    } else {//当ce是快捷方式触发的事件
		    	//s1.setData("window", gridWindow);
			      //创建并加载窗口对象
		      w = ce.getComponent().getData("window");
		    }
		    if (!desktop.getWindows().contains(w)) {
		      desktop.addWindow(w);
		    }
		    if (w != null && !w.isVisible()) {
		      w.show();
		    } else {
		      w.toFront();
		    }
		  }

	*/ 
	 public Component getDynamiCaiGouPlan(){
			
			Map<String , Object> window=new HashMap<String, Object>();
			window.put("component_model_type", ComponentTypeEnum.WINDOW_MODEL);
			window.put("title", "采购材料入库计划");
			window.put("width", 1000);
			window.put("hight", 600);
			window.put("resizable", false);
			window.put("maxmizable", true);
			window.put("minmizable", true);
			window.put("layout", ComponentTypeEnum.FITLAYOUT_MODEL);
			GxtComponentMetaNodeModel node2=new GxtComponentMetaNodeModel(window,1,44);
			
			Map<String, Object> panel=new HashMap<String, Object>();
			panel.put("component_model_type", ComponentTypeEnum.CONTENTPANEL_MODEL);
			panel.put("headervisible", false);
			panel.put("width", 1000);
			panel.put("hight", 600);
			GxtComponentMetaNodeModel node1=new GxtComponentMetaNodeModel(panel, 2, 43);
			
			

			//存储菜单栏信息
//			String[][] sub = new String[4][];
//			sub[0] = new String[6];
//				sub[0][0] = "文件";
//				sub[0][1] = "新建";
//				sub[0][2] = "保存";
//				sub[0][3] = "打印";
//				sub[0][4] = "预览";
//				sub[0][5] = "退出";
//			sub[1] = new String[3];
//				sub[1][0] = "编辑";
//				sub[1][1] = "引入";
//				sub[1][2] = "查找";
//			sub[2] = new String[6];
//				sub[2][0] = "查看";
//				sub[2][1] = "基础资料查看";
//				sub[2][2] = "编码查看";
//				sub[2][3] = "采购价格查询";
//				sub[2][4] = "历史价格查询";
//				sub[2][5] = "库存状态查询";
//			sub[3] = new String[3];
//				sub[3][0] = "选项";
//				sub[3][1] = "获取批次信息";
//				sub[3][2] = "物料配套查询录入";
			List<BaseTreeModel> listModel=new ArrayList<BaseTreeModel>();
			
			BaseTreeModel file=new BaseTreeModel();
			file.set("name", "文件");
			
			BaseTreeModel file1=new BaseTreeModel();
			file1.set("name", "新建");
			file.add(file1);
			BaseTreeModel file2=new BaseTreeModel();
			file2.set("name", "保存");
			file.add(file2);
			BaseTreeModel file3=new BaseTreeModel();
			file3.set("name", "打印");
			file.add(file3);
			BaseTreeModel file4=new BaseTreeModel();
			file4.set("name", "预览");
			file.add(file4);
			BaseTreeModel file5=new BaseTreeModel();
			file5.set("name", "退出");
			file.add(file5);
			
			BaseTreeModel edit=new BaseTreeModel();
			edit.set("name", "编辑");
			
			BaseTreeModel edit1=new BaseTreeModel();
			edit1.set("name", "引入");
			edit.add(edit1);
			BaseTreeModel edit2=new BaseTreeModel();
			edit2.set("name", "查找");
			edit.add(edit2);
			
			BaseTreeModel view=new BaseTreeModel();
			view.set("name", "查看");
			
			BaseTreeModel view1=new BaseTreeModel();
			view1.set("name", "基础资料查看");
			view.add(view1);
			BaseTreeModel view2=new BaseTreeModel();
			view2.set("name", "编码查看");
			view.add(view2);
			BaseTreeModel view3=new BaseTreeModel();
			view3.set("name", "采购价格查询");
			view.add(view3);
			BaseTreeModel view4=new BaseTreeModel();
			view4.set("name", "历史价格查询");
			view.add(view4);
			BaseTreeModel view5=new BaseTreeModel();
			view5.set("name", "库存状态查询");
			view.add(view5);
			BaseTreeModel view51=new BaseTreeModel();
			view51.set("name", "在库库存查询");
			view5.add(view51);
			BaseTreeModel view52=new BaseTreeModel();
			view52.set("name", "在途库存查询");
			view5.add(view52);
			
			
			BaseTreeModel option=new BaseTreeModel();
			option.set("name", "选项");
			
			BaseTreeModel option1=new BaseTreeModel();
			option1.set("name", "获取批次信息");
			option.add(option1);
			BaseTreeModel option2=new BaseTreeModel();
			option2.set("name", "物料配套查询录入");
			option.add(option2);
			
			listModel.add(file);
			listModel.add(edit);
			listModel.add(view);
			listModel.add(option);
			
			Map<String, Object> menubar=new HashMap<String, Object>();
			menubar.put("component_model_type", ComponentTypeEnum.MENUBAR_MODEL);
			menubar.put("menubaritem", listModel);
			GxtComponentMetaNodeModel node3=new GxtComponentMetaNodeModel(menubar, 3, 4);
			
			List<String> btn=new ArrayList<String>();
			btn.add("新建");
			btn.add("保存");
			btn.add("打开");
			btn.add("引入");
			btn.add("导出");
			
			Map<String, Object> toolbar=new HashMap<String, Object>();
			toolbar.put("component_model_type", ComponentTypeEnum.TOOLBAR_MODEL);
			toolbar.put("add", btn);
			GxtComponentMetaNodeModel node4=new GxtComponentMetaNodeModel(toolbar, 5, 6);
			
			//创建提交和取消按钮
			Map<String, Object> btnSubmit=new HashMap<String, Object>();
			btnSubmit.put("component_model_type", ComponentTypeEnum.BUTTON_MODEL);
			btnSubmit.put("text", "确定");
			GxtComponentMetaNodeModel btnSubmit1=new GxtComponentMetaNodeModel(btnSubmit);
			
			Map<String, Object> btnquxiao=new HashMap<String, Object>();
			btnquxiao.put("component_model_type", ComponentTypeEnum.BUTTON_MODEL);
			btnquxiao.put("text", "取消");
			GxtComponentMetaNodeModel btn1=new GxtComponentMetaNodeModel(btnquxiao);
			
			List<GxtComponentMetaNodeModel> list1=new ArrayList<GxtComponentMetaNodeModel>();
			list1.add(btnSubmit1);
			list1.add(btn1);
			
			
			
			Map<String, Object> MaxPanel=new HashMap<String, Object>();
			MaxPanel.put("component_model_type", ComponentTypeEnum.FORMPANEL_MODEL);
			MaxPanel.put("autowidth", true);
			MaxPanel.put("autoheight", true);
			MaxPanel.put("frame", true);
			MaxPanel.put("headervisible", false);
			MaxPanel.put("addbutton", list1);
			MaxPanel.put("buttonalign", "CENTER");
			GxtComponentMetaNodeModel node5=new GxtComponentMetaNodeModel(MaxPanel, 7, 42);
			
			Map<String, Object> topPanel=new HashMap<String, Object>();
			topPanel.put("component_model_type", ComponentTypeEnum.CONTENTPANEL_MODEL);
			topPanel.put("autowidth", true);
			topPanel.put("hight", 80);
			topPanel.put("headervisible", false);
			topPanel.put("layout", ComponentTypeEnum.COLUMNLAYOUT_MODEL);
			GxtComponentMetaNodeModel node6=new GxtComponentMetaNodeModel(topPanel, 8, 33);
			
			Map<String, Object> leftPanel=new HashMap<String, Object>();
			leftPanel.put("component_model_type", ComponentTypeEnum.CONTENTPANEL_MODEL);
//			leftPanel.put("autowidth", true);
			leftPanel.put("width", 300);
			leftPanel.put("hight", 80);
			leftPanel.put("headervisible", false);
			leftPanel.put("layout", ComponentTypeEnum.FORMLAYOUT_MODEL);
			GxtComponentMetaNodeModel node7=new GxtComponentMetaNodeModel(leftPanel, 9, 16);
			
			//编号
			Map<String, Object> id = new HashMap<String, Object>();
			id.put("component_model_type", ComponentTypeEnum.TEXTFIELD_MODEL);
			id.put("fieldlabel", "编号");
			id.put("allowblank", false);
			GxtComponentMetaNodeModel node10  = new GxtComponentMetaNodeModel(id,10,11);
			
			//入库类别
			Map<String, Object> type = new HashMap<String, Object>();
			type.put("component_model_type", ComponentTypeEnum.COMBOBOX_MODEL);
			type.put("fieldlabel", "入库类别");
			type.put("allowblank", false);
			GxtComponentMetaNodeModel node11  = new GxtComponentMetaNodeModel(type,12,13);
			
			//填单日期
			Map<String, Object> date = new HashMap<String, Object>();
			date.put("component_model_type", ComponentTypeEnum.DATEFIELD_MODEL);
			date.put("fieldlabel", "填单日期");
			date.put("allowblank", false);
			GxtComponentMetaNodeModel node12  = new GxtComponentMetaNodeModel(date,14,15);
			
			Map<String, Object> centerPanel=new HashMap<String, Object>();
			centerPanel.put("component_model_type", ComponentTypeEnum.CONTENTPANEL_MODEL);
//			centerPanel.put("autowidth", true);
			centerPanel.put("width", 300);
			centerPanel.put("hight", 80);
			centerPanel.put("headervisible", false);
			centerPanel.put("layout", ComponentTypeEnum.FORMLAYOUT_MODEL);
			GxtComponentMetaNodeModel node8=new GxtComponentMetaNodeModel(centerPanel, 17, 24);
			
			//供货商
			Map<String, Object> ghs = new HashMap<String, Object>();
			ghs.put("component_model_type", ComponentTypeEnum.TEXTFIELD_MODEL);
			ghs.put("fieldlabel", "供货商");
			ghs.put("allowblank", false);
			GxtComponentMetaNodeModel node13  = new GxtComponentMetaNodeModel(ghs,18,19);
			
			//质检方式
			Map<String, Object> zj = new HashMap<String, Object>();
			zj.put("component_model_type", ComponentTypeEnum.COMBOBOX_MODEL);
			zj.put("fieldlabel", "质检方式");
			zj.put("allowblank", false);
			GxtComponentMetaNodeModel node14  = new GxtComponentMetaNodeModel(zj,20,21);
			
			//负责人
			Map<String, Object> fzr = new HashMap<String, Object>();
			fzr.put("component_model_type", ComponentTypeEnum.TEXTFIELD_MODEL);
			fzr.put("fieldlabel", "负责人");
			fzr.put("allowblank", false);
			GxtComponentMetaNodeModel node15  = new GxtComponentMetaNodeModel(fzr,22,23);
			
			Map<String, Object> rightPanel=new HashMap<String, Object>();
			rightPanel.put("component_model_type", ComponentTypeEnum.CONTENTPANEL_MODEL);
//			rightPanel.put("autowidth", true);
			rightPanel.put("width", 300);
			rightPanel.put("hight", 80);
			rightPanel.put("headervisible", false);
			rightPanel.put("layout", ComponentTypeEnum.FORMLAYOUT_MODEL);
			GxtComponentMetaNodeModel node9=new GxtComponentMetaNodeModel(rightPanel, 25, 32);
			
			//接收仓库
			Map<String, Object> ck = new HashMap<String, Object>();
			ck.put("component_model_type", ComponentTypeEnum.COMBOBOX_MODEL);
			ck.put("fieldlabel", "接收仓库");
			ck.put("allowblank", false);
			GxtComponentMetaNodeModel node16  = new GxtComponentMetaNodeModel(ck,26,27);
			
			//是否质检
			Map<String, Object> isZj = new HashMap<String, Object>();
			isZj.put("component_model_type", ComponentTypeEnum.CHECKBOX_MODEL);
			isZj.put("fieldlabel", "是否质检");
			isZj.put("boxlabel", "是否质检");
			isZj.put("value", true);
			GxtComponentMetaNodeModel node17  = new GxtComponentMetaNodeModel(isZj,28,29);
			
			//制单
			Map<String, Object> zd = new HashMap<String, Object>();
			zd.put("component_model_type", ComponentTypeEnum.TEXTFIELD_MODEL);
			zd.put("fieldlabel", "制单");
			zd.put("allowblank", false);
			GxtComponentMetaNodeModel node18  = new GxtComponentMetaNodeModel(zd,30,31);
			
			Map<String, Object> middlePanel=new HashMap<String, Object>();
			middlePanel.put("component_model_type", ComponentTypeEnum.CONTENTPANEL_MODEL);
			middlePanel.put("autowidth", true);
			middlePanel.put("hight", 80);
			middlePanel.put("headervisible", false);
			middlePanel.put("layout", ComponentTypeEnum.FORMLAYOUT_MODEL);
			GxtComponentMetaNodeModel node19=new GxtComponentMetaNodeModel(middlePanel, 34, 37);
			
			//备注
			Map<String, Object> bz = new HashMap<String, Object>();
			bz.put("component_model_type", ComponentTypeEnum.TEXTAREA_MODEL);
			bz.put("label", "备注");
			GxtComponentMetaNodeModel node20  = new GxtComponentMetaNodeModel(bz,35,36);
			
			Map<String, Object> bottomPanel=new HashMap<String, Object>();
			bottomPanel.put("component_model_type", ComponentTypeEnum.CONTENTPANEL_MODEL);
			bottomPanel.put("autowidth", true);
			bottomPanel.put("hight", 290);
			bottomPanel.put("headervisible", false);
			GxtComponentMetaNodeModel node21=new GxtComponentMetaNodeModel(bottomPanel, 38, 41);
			
			Map<String, Object> grid=new HashMap<String, Object>();
			grid.put("component_model_type", ComponentTypeEnum.EDITABLEGRID_MODEL);
			grid.put("number",10);
			grid.put("hight",280);
			grid.put("width",950);
			GxtComponentMetaNodeModel node22=new GxtComponentMetaNodeModel(grid, 39, 40);
			
			List<GxtComponentMetaNodeModel> list=new ArrayList<GxtComponentMetaNodeModel>();
			list.add(node2);
			list.add(node1);
			list.add(node3);
			list.add(node4);
			list.add(node5);
			list.add(node6);
			list.add(node7);
			list.add(node8);
			list.add(node9);
			list.add(node10);
			list.add(node11);
			list.add(node12);
			list.add(node13);
			list.add(node14);
			list.add(node15);
			list.add(node16);
			list.add(node17);
			list.add(node18);
			list.add(node19);
			list.add(node20);
			list.add(node21);
			list.add(node22);
			
			GxtComponentMetaModel gxtComponentMetaModel=new GxtComponentMetaModel(list);
//			return GxtComponentFactory.createGxtComponent(gxtComponentMetaModel);
			return null;
		}
		
	 
	 public  void startJdkLogger() {
		  Logger rootLogger = Logger.getLogger("");
		 // rootLogger.setLevel(Level.FINE);

		  Handler[] handlers = rootLogger.getHandlers();
			//System.out.println("handlers size :"+handlers.length);

			for (int i = 0; i < handlers.length; i++) {
				//System.out.println(handlers[i].getClass());
				//System.out.println(handlers[i].getFormatter().getClass());
				handlers[i].setFormatter(new MyGwtFormatter());
			}
	}
	 
}
